package com.cloud.bc.controller.ajax;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cloud.bc.model.request.SingleListRequest;
import com.cloud.bc.model.request.VoiceListRequest;
import com.cloud.bc.model.response.AjaxResp;
import com.cloud.bc.model.response.VoiceListResponse;
import com.cloud.bc.service.BcSinglesService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

@AllArgsConstructor
@RestController
@RequestMapping("m/ajax/voice")
public class Ajax_VoiceController {

    private final BcSinglesService bcSinglesService;

    @GetMapping("list")
    public AjaxResp list(HttpServletRequest request, HttpServletResponse response,
                         VoiceListRequest req) {
        AjaxResp ajaxResp = new AjaxResp();
        Page page = new Page();
        page.setSize(10);
        page.setCurrent(req.getPage());
        List<VoiceListResponse> list = bcSinglesService.selectVoiceList(page, req);
        ajaxResp.setList(list);
        return ajaxResp;
    }
}
